<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<h2>这是标题</h2>
<script>
    var cssTag = document.createElement('style');
    var textNode = document.createTextNode('h2{color:red}');
    cssTag.appendChild(textNode);
    document.head.appendChild(cssTag);
</script>
</body>
</html>